package br.livro.android.cap5;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ExemploSimularLigacao extends Activity implements OnClickListener{
	
	private Button btnLigar;
	private EditText txtNum;
	
	@Override
	public void onCreate(Bundle icicle){
		super.onCreate(icicle);
		setContentView(R.layout.layout_simular_ligacao);
		
		this.btnLigar = (Button) findViewById(R.id.btnLigar);
		this.txtNum = (EditText) findViewById(R.id.txtNum);
		this.btnLigar.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		//Telefone que vamos ligar
		Uri uri = Uri.parse("tel:"+this.txtNum.getText().toString());
		//Cria a intent com o numero
		Intent it = new Intent(Intent.ACTION_CALL,uri);
		//Envia a mensagem ao sistema operacional
		startActivity(it);
	}

}
